package com.servicesystem.servicesystem.controller.douyin;

import com.alibaba.fastjson.JSON;
import com.servicesystem.servicesystem.entity.douyin.vo.product.AddProductSkuVO;
import com.servicesystem.servicesystem.entity.douyin.vo.product.AddSpecsVO;
import com.servicesystem.servicesystem.service.GoodsLibService;
import com.servicesystem.servicesystem.entity.douyin.vo.oauth.OauthVO;
import com.servicesystem.servicesystem.entity.douyin.vo.product.AddProductVO;
import com.servicesystem.servicesystem.service.ProductService;
import com.servicesystem.servicesystem.untis.HttpRequestAll;
import com.servicesystem.servicesystem.untis.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * @author X
 * @version 1.0
 * @ClassName ProductController
 * @description
 * @date 2020/9/9
 **/
@RestController
@RequestMapping("/douyin/product")
public class ProductController {

    @Autowired
    private ProductService productService;

    /***
     * 向抖店添加商品
     * @return
     */
    @PostMapping("/addProduct")
    public R addProduct(@RequestBody AddProductVO addProductVO) throws Exception {

        String result = productService.addProduct(addProductVO);
        return R.success(result);
    }

    /***
     * 删除抖店商品
     * @return
     */
    @PostMapping("/deleteProduct/{productId}")
    public R deleteProduct(@PathVariable(value = "productId") String productId) throws Exception {

        String result = productService.deleteProduct(productId);
        return R.success(result);
    }

    /***
     * 获取商品详细
     * @return
     */
    @PostMapping("/productDetail/{productId}")
    public R productDetail(@PathVariable(value = "productId") String productId) throws Exception {

        String result = productService.productDetail(productId);
        return R.success(result);
    }

    /***
     * 添加商品规格
     * @param addSpecsVO
     * @return
     * @throws Exception
     */
    @PostMapping("/addSpec")
    public R addSpec(@RequestBody AddSpecsVO addSpecsVO) throws Exception {
        String result = productService.addSpec(addSpecsVO);
        return R.success(result);
    }

    /***
     * 获得规格
     * @param
     * @return
     * @throws Exception
     */
    @GetMapping("/getSpec")
    public R getSpec() throws Exception {
        String result = productService.getSpec();
        return R.success(result);
    }

    /***
     * 获取商品分类列表
     * @param
     * @return
     * @throws Exception
     */
    @GetMapping("/getGoodsCategory/{cunt}")
    public R getGoodsCategory(@PathVariable(value = "cunt") String cunt) throws Exception {
        String result = productService.getGoodsCategory(cunt);
        return R.success(result);
    }

    /***
     * 添加商品SKU
     * @param addProductSkuVO
     * @return
     * @throws Exception
     */
    @PostMapping("/addGoodsSku")
    public R addGoodsSku(@RequestBody AddProductSkuVO addProductSkuVO) throws Exception {
        String result = productService.addGoodsSku(addProductSkuVO);
        return R.success(result);
    }

    /***
     * 批量添加添加商品SKU
     * @param addProductSkuVO
     * @return
     * @throws Exception
     */
    @PostMapping("/addGoodsSkuAll")
    public R addGoodsSkuAll(@RequestBody AddProductSkuVO addProductSkuVO) throws Exception {
        String result = productService.addGoodsSkuAll(addProductSkuVO);
        return R.success(result);
    }


    /***
     * 获取规格列表
     * @param
     * @return
     * @throws Exception
     */
    @PostMapping("/getSpecList")
    public R getSpecList() throws Exception {
        String result = productService.getSpecList();
        return R.success(result);
    }

    /***
     * 获取规格详情
     * @param
     * @return
     * @throws Exception
     */
    @PostMapping("/getSpecDetail/{specId}")
    public R getSpecDetail(@PathVariable(value = "specId") String specId) throws Exception {
        String result = productService.getSpecDetail(specId);
        return R.success(result);
    }

    /***
     * 获取商品sku列表
     * @param
     * @return
     * @throws Exception
     */
    @PostMapping("/getSkuList/{productId}")
    public R getSkuList(@PathVariable(value = "productId") String productId) throws Exception {
        String result = productService.getSkuList(productId);
        return R.success(result);
    }
}
